// pages/shop/shop.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeType: '2',
    typeList: [{
      id: '1',
      name: '丰田啊艾尔法'
    }, {
      id: '2',
      name: '别克-GL8-ES653T'
    }, {
      id: '3',
      name: '丰田啊艾尔法'
    }, {
      id: '4',
      name: '别克-GL8-ES653T'
    }, {
      id: '5',
      name: '丰田啊艾尔法'
    }, {
      id: '6',
      name: '别克-GL8-ES653T'
    }, {
      id: '7',
      name: '丰田啊艾尔法'
    }, {
      id: '8',
      name: '别克-GL8-ES653T'
    }, {
      id: '9',
      name: '丰田啊艾尔法'
    }, {
      id: '10',
      name: '别克-GL8-ES653T'
    }],
    serialData: {},
    mockSerialData: {
      id: '2',
      serialList: [{
        id: '1',
        title: '系列1',
        image: 'http://localhost:8000/images/serial-1.png',
        description: '这里是描述描述描述描述这里是描述描述描述描述~~',
        items: [{
          id: '1',
          name: '组件1',
          image: 'http://localhost:8000/images/item-1.png'
        }, {
          id: '2',
          name: '组件2组件2组件2组件2组件2',
          image: 'http://localhost:8000/images/item-2.png'
        }, {
          id: '3',
          name: '组件3',
          image: 'http://localhost:8000/images/item-3.png'
        }, {
          id: '4',
          name: '组件4',
          image: 'http://localhost:8000/images/item-1.png'
        }, {
          id: '5',
          name: '组件5',
          image: 'http://localhost:8000/images/item-3.png'
        }]
      }, {
        id: '2',
        title: '系列2',
        image: 'http://localhost:8000/images/serial-1.png',
        description: '这里是描述描述描述描述这里是描述描述描述描述~~',
        items: [{
          id: '1',
          name: '组件1',
          image: 'http://localhost:8000/images/item-1.png'
        }, {
          id: '2',
          name: '组件2',
          image: 'http://localhost:8000/images/item-2.png'
        }, {
          id: '3',
          name: '组件3',
          image: 'http://localhost:8000/images/item-3.png'
        }, {
          id: '4',
          name: '组件4',
          image: 'http://localhost:8000/images/item-1.png'
        }, {
          id: '5',
          name: '组件5',
          image: 'http://localhost:8000/images/item-3.png'
        }]
      }]
    }
  },

  changeType(e) {
    const id = e.target.dataset.id
    this.setData({
      activeType: id
    })
    if (id === '2') {
      this.setData({
        serialData: this.getSerialData('2')
      })
    } else {
      this.setData({
        serialData: {}
      })
    }
  },

  getSerialData(type) {
    if (type === '2') {
      return this.data.mockSerialData
    }
    return {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      serialData: this.getSerialData('2')
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})